package com.bryanbibat.flashcards.robot;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class CommandParserTest {
  
  @Test
  public void correct_basic() {
    CommandParser cp = new CommandParser("deal hiragana");
    
    assertEquals("hiragana", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(10, cp.getSettings().getRounds());
  }
  
  
  @Test
  public void correct_rounds() {
    CommandParser cp = new CommandParser("deal 1 20 rounds");
    
    assertEquals("1", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(20, cp.getSettings().getRounds());
  }
  
  @Test
  public void multiple_rounds() {
    CommandParser cp = new CommandParser("deal 1 rounds 20 rounds 10");
    
    assertEquals("1", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(20, cp.getSettings().getRounds());
  }
  
  @Test
  public void incorrect_rounds() {
    CommandParser cp = new CommandParser("deal 1 2a0 rounds");
    
    assertEquals("1", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(10, cp.getSettings().getRounds());
  }

  @Test
  public void correct_choices() {
    CommandParser cp = new CommandParser("deal 1 6 choices");
    
    assertEquals("1", cp.getId());
    assertEquals(6, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(10, cp.getSettings().getRounds());
  }

  
  @Test
  public void incorrect_choices() {
    CommandParser cp = new CommandParser("deal 1 2a0 choices");
    
    assertEquals("1", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(10, cp.getSettings().getRounds());
  }
  
  @Test
  public void shuffle_choices() {
    CommandParser cp = new CommandParser("deal 1 6 choices 20 rounds ");
    
    assertEquals("1", cp.getId());
    assertEquals(6, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(20, cp.getSettings().getRounds());
  }
  
  @Test
  public void correct_penalty() {
    CommandParser cp = new CommandParser("deal 1 6 penalty ");
    
    assertEquals("1", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(6, cp.getSettings().getPenalty());
    assertEquals(10, cp.getSettings().getRounds());
  }

  @Test
  public void incorrect_penalty() {
    CommandParser cp = new CommandParser("deal 1 2a0 penalty 20 rounds");
    
    assertEquals("1", cp.getId());
    assertEquals(3, cp.getSettings().getChoices());
    assertEquals(1, cp.getSettings().getPenalty());
    assertEquals(20, cp.getSettings().getRounds());
  }

}
